package service

import (
	"singo/model"
	"singo/serializer"
)

// TaskShowService 需求详情的服务
type TaskShowService struct {
}

// TaskShow 需求
func (service *TaskShowService) TaskShow(uid string) serializer.Response {
	var task model.Task
	err := model.DB.First(&task, "uid = ?", uid).Error
	if err != nil {
		return serializer.Response{
			Status: 404,
			Msg:    "需求不存在",
			Error:  err.Error(),
		}
	}

	return serializer.Response{
		Data: serializer.BuildTask(task),
	}
}
